<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // var arr = [1, 2, 3]
        // console.log([...arr]);

        // var obj = {
        //     name: '张三',
        //     age: 15,
        //     tel: 123
        // }


        // var obj2 = {
        //     sex: '女'
        // }


        // var obj3 = {...obj, ...obj2}
        // console.log(obj3);
        // var arr = [1, 2, 3, 4]

        // var arr2 = [5, 6, 7]

        // var arr3 = [...arr, ...arr2]
        // console.log(arr3);

            // var arr = [1, 2, 3]

            // var [a, ...b] = arr

            // console.log(b);

            var obj = {
                name: '张三',
                age: 16,
                sex: '男',
                info:{
                    isSingle:false
                }
            }


            var {name, ...obj2}  = obj 

            console.log(obj2);

            obj2.info.isSingle = true

            console.log(obj);


            var arr = [1, [2, 3, 4, [5]], 6]  //=> [1, 2, 3, 4, 5, 6]


            function fat(params) {
                var newArr = []
                if(Array.isArray(params)) {
                    params.forEach(item => {
                        if(Array.isArray(item)) {
                            newArr = newArr.concat(fat(item))
                        } else {
                            newArr.push(item)
                        }
                    })
                }

                return newArr
            }

            // var arr2 = fat(arr)

            // console.log(arr2);

            var arr2 = arr.flat(Infinity)

            console.log(arr2);
    </script>
</body>
</html>